<template>
    <view class="container">
        <!-- 导航栏 -->
        <view class="nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
            <view class="nav-back" @click="goBack">←</view>
            <view class="nav-title">导航</view>
            <view class="nav-actions">···</view>
        </view>

        <!-- 地图区域 -->
        <view class="map-container">
            <image src="/static/image/repair/map1.png" mode="widthFix" class="map-image"></image>
            <view class="destination-info">
                <view class="destination-name">山阳区人民西路32号</view>
            </view>
        </view>

        <!-- 目的地信息 -->
        <view class="destination-details">
            <view class="shop-name">{{ destination.name }}</view>
            <view class="shop-address">{{ destination.address }}</view>

            <view class="nav-btn" @click="startNavigation">导航</view>
        </view>
    </view>
</template>

<script setup>
import { reactive, onMounted, ref } from 'vue';

// 响应式数据
const destination = reactive({
    name: '车百事汽车生活馆',
    address: '山阳区人民路与解放路交叉口'
});

// 响应式数据
const statusBarHeight = ref(0);

// 方法定义
function goBack() {
    uni.navigateBack();
}

function startNavigation() {
    // 调用地图导航API
    uni.showToast({
        title: '开始导航',
        icon: 'success'
    });
    // 实际项目中这里可以调用原生地图导航
    console.log('导航到:', destination.address);
}

onMounted(() => {
    // 获取状态栏高度，使用推荐的wx.getWindowInfo API
    try {
        const windowInfo = uni.getWindowInfo();
        statusBarHeight.value = windowInfo.statusBarHeight;
    } catch (error) {
        console.error('获取窗口信息失败:', error);
        statusBarHeight.value = 0;
    }
});
</script>

<style>
.container {
    background-color: #f5f5f5;
    min-height: 100vh;
}

.nav-bar {
    height: 88rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1E88E5;
    color: white;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-back {
    font-size: 20px;
}

.nav-title {
    font-size: 18px;
    font-weight: bold;
}

.map-container {
    position: relative;
    height: 65vh;
}

.map-image {
    width: 100%;
    height: 100%;
}

.destination-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: bold;
    color: #333;
}

.destination-details {
    background-color: white;
    padding: 20px;
    margin-top: 20px;
}

.shop-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.shop-address {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.nav-btn {
    background-color: #1E88E5;
    color: white;
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 16px;
}
</style>